<template>
	<view class="flex-col page">
		<view>
			<view :style="{height:statusBarHeight+'px'}"></view>
			<u-navbar title="生日专区" bgColor="#F5F5F5" style="font-size: 30rpx;font-weight: bold;" @leftClick="$nav(2)">	
			</u-navbar>
		</view>
		
		<image mode="widthFix" class="top-bg" src="https://ysmz.scmzhc.com/static/mini/images/home/custom/birthday_bg.png"></image>
		<!-- <view class="tab-center">
			<view @click="tabChange(1)" :class="current == 1 ? 'select_bg' : 'un_select'">蛋糕糕点</view>
			<view @click="tabChange(0)" :class="current == 0 ? 'select_bg' : 'un_select'">代金券</view>
		</view> -->
		
		
		<view class="flex-col content-bg" style="min-height: 60vh;" v-if="list.length > 0">
			<ProductItem :list="list"></ProductItem>
			
			<u-loadmore margin-top="20" margin-bottom="20" :status="status" icon-type="flower"
				:load-text="loadText" color="#999"/>
		</view>
		
		<view v-else class="flex-col items-center empty-bg" style="margin-top: 80rpx;min-height: 60vh;">
			<image src="/static/data_empty.png" style="width: 260rpx;height: 220rpx;"></image>
			<text style="color: #fff;font-size: 26rpx;">暂无数据</text>
		</view>
		
	</view>
</template>

<script>
	import ProductItem from '@/components/product-item.vue';
	export default {
		data() {
			return {
				page:1,
				status: 'loadmore',
				loadText: {
					loadmore: '下拉加载更多...',
					loading: '加载中...',
					nomore: '没有更多数据了...'
				},
				list:[],
				current:1
			};
		},
		components:{
			ProductItem
		},
		computed:{
			statusBarHeight(){
				return this.$store.state.statusBarHeight + 44
			}
		},
		onLoad() {
			this.list = [];
			this.page = 1;
			this.goodsList();
		},
		onShow() {
			
		},
		onPullDownRefresh() {
			this.list = [];
			this.page = 1;
			this.goodsList();
		},
		onReachBottom() {
			this.goodsList();
		},
		methods:{
			// tabChange(index){
			// 	this.current = index;
			// 	this.list = [];
			// 	this.page = 1;
			// 	this.goodsList();
			// },
			
			goodsList(){
				// let type = 6;
				// if(this.current == 0){
				// 	type = 6;
				// }else{
				// 	type = 5;
				// }
				this.$request({
					url:'?c=Goods&a=goodsList',
					type:'post',
					data:{
						// goods_type:type,
						page:this.page,
						limit: 10,
						section_id:2
					}
				}).then(res =>{
					uni.stopPullDownRefresh();
					this.status = 'loadmore';
					if (res.data && res.data.length > 0) {
						this.list = [...this.list, ...res.data];
						this.page += 1;
						if (res.data.length < 10) {
							this.status = 'nomore';
						}
					} else {
						this.status = 'nomore';
					}
					
				});
			}
		}
	}
</script>

<style lang="scss">
.page{
	width: 100%;
	overflow-y: auto;
	overflow-x: hidden;
	height: 100%;
	background-color: #FB8D3E;
}
.top-bg{
	width: 100%;
	// height: 50%;
}
.content-bg{
	background: linear-gradient(to bottom, #FB8D3E, #fff);
}
.empty-bg{
	background: linear-gradient(to bottom, #FB8D3E, #fff);
}
.tab-center{
	border: 1rpx #fff solid;
	height: 85rpx;
	// width: 100%;
	margin-left: 50rpx;
	margin-right: 50rpx;
	border-radius: 45rpx;
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	color: #fff;
	margin-bottom: 20rpx;
}
.select_bg{
	width: 50%;
	height: 85rpx;
	background-color: #fff;
	border-radius: 45rpx;
	color: #FB8D3E;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
}
.un_select{
	width: 50%;
	height: 85rpx;
	background-color: rgba(0, 0, 0, 0);
	color: #fff;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
}
</style>
